﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Account/Site.master" AutoEventWireup="true" CodeFile="ctSanPham.aspx.cs" Inherits="Administrator_ctSanPham" %>

<%@ Register assembly="FredCK.FCKeditorV2" namespace="FredCK.FCKeditorV2" tagprefix="FCKeditorV2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" 
        Font-Size="0.8em" PathSeparator=" : " style="font-size: small">
        <CurrentNodeStyle ForeColor="#333333" />
        <NodeStyle Font-Bold="True" ForeColor="#284E98" />
        <PathSeparatorStyle Font-Bold="True" ForeColor="#507CD1" />
        <RootNodeStyle Font-Bold="True" ForeColor="#507CD1" />
    </asp:SiteMapPath>
    <br />
    <asp:Label ID="Label1" runat="server" 
        style="font-size: x-large; font-weight: 700" 
        Text="Quản lý chi tiết sản phẩm"></asp:Label>
    <br />
    <br />
    <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
        DeleteCommand="UPDATE SanPham SET Xoa = 1 WHERE (MaSanPham = @MaSanPham)" 
        InsertCommand="INSERT INTO SanPham(MaSanPham, GiaBan, LoaiID, Xoa, GioiThieu, ChucNangID, NhanHieuID, NgayCapNhat, Hot) VALUES (@MaSanPham, @GiaBan, @LoaiID, 0, @GioiThieu, @ChucNangID, @NhanHieuID, GETDATE(), @Hot)" 
        SelectCommand="SELECT * FROM [SanPham] where MaSanPham=@ID" 
        
        
        
        
        
        UpdateCommand="UPDATE SanPham SET GiaBan = @GiaBan, NgayCapNhat = GETDATE(), LoaiID = @LoaiID, Xoa = 0, GioiThieu = @GioiThieu, ChucNangID = @ChucNangID, NhanHieuID = @NhanHieuID, Hot = @Hot WHERE (MaSanPham = @MaSanPham)">
        <DeleteParameters>
            <asp:Parameter Name="MaSanPham" Type="String" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="MaSanPham" Type="String" />
            <asp:Parameter Name="GiaBan" Type="Double" />
            <asp:Parameter Name="LoaiID" Type="Int32" />
            <asp:Parameter Name="GioiThieu" Type="String" />
            <asp:Parameter Name="ChucNangID" Type="Int32" />
            <asp:Parameter Name="NhanHieuID" Type="Int32" />
            <asp:Parameter Name="Hot" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="ID" QueryStringField="ID" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="GiaBan" Type="Double" />
            <asp:Parameter Name="LoaiID" Type="Int32" />
            <asp:Parameter Name="GioiThieu" Type="String" />
            <asp:Parameter Name="ChucNangID" Type="Int32" />
            <asp:Parameter Name="NhanHieuID" Type="Int32" />
            <asp:Parameter Name="Hot" />
            <asp:Parameter Name="MaSanPham" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="MaSanPham" 
        DataSourceID="SqlDataSource5" EnableModelValidation="True" 
        CellPadding="4" Width="100%" 
        oniteminserted="FormView1_ItemInserted" ForeColor="#333333" 
        onitemdeleted="FormView1_ItemDeleted" 
        oniteminserting="FormView1_ItemInserting">
        <EditItemTemplate>
            <table class="style1" width="100%">
                <tr>
                    <td align="right" width="40%">
                        Mã sản phẩm</td>
                    <td>
                        <asp:TextBox ID="MaSanPhamTextBox" runat="server" 
                            Text='<%# Bind("MaSanPham") %>' ReadOnly="True" />
                    </td>
                </tr>
                <tr>
                    <td align="right" width="40%">
                        Giá bán</td>
                    <td>
                        <asp:TextBox ID="GiaBanTextBox0" runat="server" Text='<%# Bind("GiaBan") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right" width="40%">
                        Hot</td>
                    <td>
                        <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# Bind("Hot") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right" width="40%">
                        Loại SP</td>
                    <td>
                        <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="Loai" 
                            DataTextField="TenLoai" DataValueField="ID" 
                            SelectedValue='<%# Bind("LoaiID") %>' Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right" width="40%">
                        Thương hiệu</td>
                    <td>
                        <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="ThuongHieu" 
                            DataTextField="Ten" DataValueField="ID" 
                            SelectedValue='<%# Bind("NhanHieuID") %>' Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right" width="40%" height="0px">
                        &nbsp;</td>
                    <td>
                        <asp:DropDownList ID="DropDownList6" runat="server" DataSourceID="ChucNang" 
                            DataTextField="Ten" DataValueField="ID" 
                            SelectedValue='<%# Bind("ChucNangID") %>' Width="200px" 
                            AppendDataBoundItems="True" Visible="False">
                            <asp:ListItem></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        Giới thiệu
                        <FCKeditorV2:FCKeditor ID="FCKeditor2" runat="server" BasePath="~/fckeditor/" 
                            Height="400px" Value='<%# Bind("GioiThieu") %>' Width="100%">
                        </FCKeditorV2:FCKeditor>
                    </td>
                </tr>
            </table>
            <asp:SqlDataSource ID="Loai" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
                SelectCommand="SELECT [ID], [TenLoai] FROM [Loai] WHERE ([Xoa] = @Xoa)">
                <SelectParameters>
                    <asp:Parameter DefaultValue="false" Name="Xoa" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="ThuongHieu" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
                SelectCommand="SELECT [ID], [Ten] FROM [NhanHieu] WHERE ([Xoa] = @Xoa)">
                <SelectParameters>
                    <asp:Parameter DefaultValue="false" Name="Xoa" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:SqlDataSource ID="ChucNang" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
                SelectCommand="SELECT [ID], [Ten] FROM [ChucNang] WHERE ([Xoa] = @Xoa)">
                <SelectParameters>
                    <asp:Parameter DefaultValue="false" Name="Xoa" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" 
                CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <InsertItemTemplate>
            <table class="style1" width="100%">
                <tr>
                    <td align="right">
                        Mã sản phẩm</td>
                    <td>
                        <asp:TextBox ID="MaSanPhamTextBox" runat="server" 
                            Text='<%# Bind("MaSanPham") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Giá bán</td>
                    <td>
                        <asp:TextBox ID="GiaBanTextBox0" runat="server" Text='<%# Bind("GiaBan") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Hot</td>
                    <td>
                        <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Hot") %>' />
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Thương hiệu</td>
                    <td>
                        <asp:DropDownList ID="DropDownList5" runat="server" DataSourceID="ThuongHieu" 
                            DataTextField="Ten" DataValueField="ID" 
                            SelectedValue='<%# Bind("NhanHieuID") %>' Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        Loại SP</td>
                    <td>
                        <asp:DropDownList ID="DropDownList4" runat="server" DataSourceID="Loai" 
                            DataTextField="TenLoai" DataValueField="ID" 
                            SelectedValue='<%# Bind("LoaiID") %>' Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right" height="0px">
                        &nbsp;</td>
                    <td>
                        <asp:DropDownList ID="DropDownList6" runat="server" DataSourceID="ChucNang" 
                            DataTextField="Ten" DataValueField="ID" 
                            SelectedValue='<%# Bind("ChucNangID") %>' Width="200px" 
                            AppendDataBoundItems="True" Visible="False">
                            <asp:ListItem></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        Giới thiệu
                        <FCKeditorV2:FCKeditor ID="FCKeditor2" runat="server" BasePath="~/fckeditor/" 
                            Height="400px" Value='<%# Bind("GioiThieu") %>' Width="100%">
                        </FCKeditorV2:FCKeditor>
                    </td>
                </tr>
            </table>
            <asp:SqlDataSource ID="Loai" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
                SelectCommand="SELECT [ID], [TenLoai] FROM [Loai] WHERE ([Xoa] = @Xoa)">
                <SelectParameters>
                    <asp:Parameter DefaultValue="false" Name="Xoa" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                ControlToValidate="MaSanPhamTextBox" Display="None" 
                ErrorMessage="Mã sản phẩm không được rỗng"></asp:RequiredFieldValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                ControlToValidate="GiaBanTextBox0" Display="None" 
                ErrorMessage="Giá không được rỗng"></asp:RequiredFieldValidator>
            <asp:SqlDataSource ID="ThuongHieu" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
                SelectCommand="SELECT [ID], [Ten] FROM [NhanHieu] WHERE ([Xoa] = @Xoa)">
                <SelectParameters>
                    <asp:Parameter DefaultValue="false" Name="Xoa" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
            <asp:SqlDataSource ID="ChucNang" runat="server" 
                ConnectionString="<%$ ConnectionStrings:ConnectServer %>" 
                SelectCommand="SELECT [ID], [Ten] FROM [ChucNang] WHERE ([Xoa] = @Xoa)">
                <SelectParameters>
                    <asp:Parameter DefaultValue="false" Name="Xoa" Type="Boolean" />
                </SelectParameters>
            </asp:SqlDataSource>
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Lưu " />
            &nbsp;&nbsp;
            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" 
                CommandName="Cancel" Text="Cancel" onclick="InsertCancelButton_Click" />
        </InsertItemTemplate>
        <ItemTemplate>
            <strong>MaSanPham:</strong>
            <asp:Label ID="MaSanPhamLabel" runat="server" Text='<%# Eval("MaSanPham") %>' />
            <br />
            <strong>GiaBan:</strong>
            <asp:Label ID="GiaBanLabel" runat="server" Text='<%# Bind("GiaBan") %>' />
            <br />
            <strong>NgayCapNhat:</strong>
            <asp:Label ID="NgayCapNhatLabel" runat="server" 
                Text='<%# Bind("NgayCapNhat") %>' />
            <br />
            <strong>LoaiID:</strong>
            <asp:Label ID="LoaiIDLabel" runat="server" Text='<%# Bind("LoaiID") %>' />
            <br />
            <strong>Hot: </strong>
            <asp:CheckBox ID="CheckBox3" runat="server" Checked='<%# Bind("Hot") %>' 
                Enabled="False" />
            <br />
            <strong>NhanHieuID:</strong>
            <asp:Label ID="NhanHieuIDLabel" runat="server" 
                Text='<%# Bind("NhanHieuID") %>' />
            <br />
            <strong>GioiThieu:</strong>
            <asp:Label ID="GioiThieuLabel" runat="server" Text='<%# Bind("GioiThieu") %>' />
            <br />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Sửa " />
            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Xóa" />
            &nbsp;
        </ItemTemplate>
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    </asp:FormView>
    <asp:LinkButton ID="LinkButton1" runat="server" 
        PostBackUrl="~/Administrator/SanPham.aspx" CausesValidation="False">Quan lại trang sản phẩm</asp:LinkButton>
    <br />
</asp:Content>

